summaryrefslogtreecommitdiff
path: root/src/pages/[locale]/news/[...slug].astro
blob: 580f4a38cd36c6a625defe1dfc30407ce0437878 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
import Article from '$layouts/Article.astro';
import { getCollection, render } from 'astro:content';
import { getDate, getLocale, getSlug } from '$lib/newsUtils';

export async function getStaticPaths() {
  return (await getCollection('news')).map((entry) => ({
    params: {
      slug: getSlug(entry),
      locale: getLocale(entry),
    },
    props: { entry },
  }));
}

const { entry } = Astro.props;
const { Content } = await render(entry);

const publicationDate = getDate(entry);
---

<Article title={entry.data.title}>
  <section>
    <h1>{entry.data.title}</h1>
    <time datetime={publicationDate?.toISOString()}>
      {
        publicationDate?.toLocaleDateString('en-GB', {
          day: 'numeric',
          month: 'short',
          year: 'numeric',
        })
      }
    </time>
    <Content />
  </section>
</Article>